package cn.boge.best.service.impl;

import cn.boge.best.mapper.BestMapper;
import cn.boge.best.query.BestQuery;
import cn.boge.best.service.IBestService;
import cn.boge.org.domain.Department;
import cn.boge.org.mapper.DepartmentMapper;
import cn.boge.org.query.DeptQuery;
import cn.boge.org.utils.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class BestServiceImpl<T> implements IBestService<T> {
    @Autowired
    private BestMapper<T> bestMapper;

    @Override
    @Transactional
    public void add(T t) {
        //包含主键的department对象
        bestMapper.add(t);
    }

    @Override
    @Transactional
    public void upt(T t) {
        bestMapper.upt(t);
    }

    @Override
    @Transactional
    public void del(Long id) {
        bestMapper.del(id);
    }

    @Override
    public List<T> findAll() {
        return bestMapper.findAll();
    }

    @Override
    public T findById(Long id) {
        return bestMapper.findById(id);
    }

    @Override
    public QueryResult<T> findByQuery(BestQuery query) {
        Long totals = bestMapper.queryCount(query);
        List<T> data =bestMapper.quertData(query);
        return new QueryResult<>(totals,data);
    }

    @Override
    @Transactional
    public void delpatch(List<Long> ids) {
        bestMapper.delpatch(ids);
    }
}
